package persistency.reader;

/**
 * TeacherReader.java
 * Purpose: this class represents a course that students can take
 * 
 * @author Hans Brems
 * @version 1.0 05/11/2011
 */

import java.util.ArrayList;

import model.Teacher;

public class TeacherReader extends ContentReader {
	
	/** Constructs a teacher reader object */
	public TeacherReader() {
	}
	
	/** Constructs a teacher reader object */
	public TeacherReader(String filePath) {
		super(filePath);
	}
	
	/** Reads a text file containing teacher objects into a collection */
	public ArrayList<Teacher> read() {
		
		// Create list
		ArrayList<Teacher> teachers = new ArrayList<Teacher>();
		
		// Skip the first line (header)
		this.scanner.nextLine();

		// Construct a course object from each line
		while (this.scanner.hasNext()) {
			
			// Create a new teacher
			Teacher teacher = new Teacher();
			
			// Set course values
			String code = this.scanner.next();
			teacher.setTeacherCode(code);
			String name = this.scanner.next();
			teacher.setTeacherName(name);
			String hours = this.scanner.next();
			teacher.setAmountWantedHours(Integer.parseInt(hours));
			
			// Add course to collection
			teachers.add(teacher);
		}
		
		// Return list
		return teachers;
	}
}